

$(function(){
	
	//1、全局token开始,拿到ID
	var url =  window.parent.parent.location.href;
	var token = url.split("token")[1];
	token=token.slice(1);
	console.log("student-manager.html的token="+token);
	//1、全局token结束
	
	//2、解析出上下文逻辑开始 拿到 http://localhost:8080/
	var context = getRootPath();
	console.log("context="+context);
	//2、解析出上下文逻辑结束
	
	
	//3、角色分页列表页面开始
	var vue =new Vue({
		el:'#studentListTable',
		data:{
			student:[],
	
		},
		methods:{
			//拿到角色分页列表的数据
			getStudentMessage:function(){
				 var url=context+'student/StudentMessage'
				 console.log(url)
				
				axios.get(url).then(function(dataR){
					console.log(dataR);
					
					
					var code =dataR.data.code;
					var data=dataR.data.data;
					var studentList=data.studentList;
					vue.student=studentList;
					
					
				});
				
			},
			tableUpdateStudentButton:function(index){
				console.log("index="+index);
				
				var student = this.students[index];
				console.log(student);
				
				var id =student.id;
				var studentName=student.studentName;
				var studentCode=student.studentCode;
				//1.1：填充表格
				$('p[name="updateStudentId"]').text(id);
				$('input[name="updateStudentId"]').val(id);
				$('input[name="updateStudentName"]').val(studentName);
				$('input[name="updateStudentPhone"]').val(studentPhone);
				$('input[name="updateStudentEducation"]').val(studentEducation);
				
				//1.2：打开模态框
				$('#updateStudentModal').modal({
					backdrop:"static",
				});
			}
		}
	});
	vue.getStudentMessage();
	//3、角色分页列表页面结束
	
	
	

	
	//单击编辑角色模块框中的保存按钮 开始-------------------------------------- 
	$('#modalUpdateStudentButton').click(function(){
		
		//2.1:收集表单数据并向后台发送请求
		var id=$("input[name='updateStudentId']").val();
		var studentName=$("input[name='updateStudentName']").val();
		var studentPhone=$("input[name='updateStudentPhone']").val();
		var studentEducation=$("input[name='updateStudentEducation']").val();

		var data={
			id:id,
			studentName:studentName,
			studentPhone:studentPhone,
			studentEducation:studentEducation
			token:token
		}
		
		var url=getRootPath()+'student/update';
		var callback=function(dataR){
			var code=dataR.code;
			if(code==200){
				//2.2:关闭修改模态框
				$('#updateStudentModal').modal('hide');
				
				//2.3:刷新刷新页面数据
				vue.getStudentListPage(1,pageSize);
				
			}
			
		};
		send(url,data,callback);
	});
	//单击编辑角色模块框中的保存按钮 结束-------------------------------------- 
	
	
	
	
	
});
